# from selenium import webdriver
# import time
#
# browser = webdriver.Chrome()
#
# browser.get('https://www.meishij.net/fenlei/xiafancai/')
# time.sleep(3)
# browser.execute_script('window. scrollTo(0, document.body. scrollHeight)')
# time.sleep(2)
# browser.execute_script('alert("到达页面底部啦")')



# 发起http请求，获得网页源代码2 import requests
# 解析html源代码
import requests
from bs4 import BeautifulSoup

# def my_id(ip):
#     # 要查询的ip地址
#     url = "https://ip.hao86.com/" + ip + "/"
#     #print (url)
#
#     # 获取源代码
#     r = requests.get(url)
#     # print(r.status_code)
#     r.encoding ="UTF-8"
#     # print(r.text)
#     # 实例化bs对象
#     # body > div.comm-content-box.clearfloat > div > div.comm-content-left.clearfloat > div > div.xq_toggle > div:nth-child(2) > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(2)
#     soup = BeautifulSoup(r.text,'html.parser')
#     address = soup.select('body > div.comm-content-box.clearfloat > div > div.comm-content-left.clearfloat > div > div.xq_toggle > div:nth-child(2) > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(2)')
#     print(address[0].string)
#
#
# ips = "39.149.194.186"
# my_id(ips)



import requests
from bs4 import BeautifulSoup

url = "https://pic.netbian.com/"
#print (url)

# 获取源代码
r = requests.get(url)
# print(r.status_code)
r.encoding ="UTF-8"
# print(r.text)

# 实例化bs对象
soup = BeautifulSoup(r.text,'html.parser')
for i in range(1,21):
    address = soup.select('#main > div.slist > ul > li:nth-child(' + str(i) + ') > a')
    add = str(address[0].get('href')).split('/')[2]
    addr = add.split('.')[0]
    urls = 'https://pic.netbian.com/tupian/' + addr + '.html'
    rs = requests.get(urls)
    r.encoding = "UTF-8"

    print('>>',addr)





